# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=faad2
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.8.6
pkgrel=1
pkgdesc="ISO AAC audio decoder (mingw-w64)"
arch=('any')
url="http://www.audiocoding.com/"
license=('GPL')
options=('staticlibs' 'strip')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("yasm" "${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=(https://downloads.sourceforge.net/sourceforge/faac/${_realname}-${pkgver}.tar.gz)
sha256sums=('654977adbf62eb81f4fca00152aca58ce3b6dd157181b9edd7bed687a7c73f21')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  WANT_AUTOMAKE=latest autoreconf --force --install
}

build() {
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p "${srcdir}"/build-${MINGW_CHOST} && cd "${srcdir}"/build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
